package com.osce.score.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csce.domain.entity.score.ScoreExModelPlace;
import com.doudou.core.container.ListUtil;
import com.osce.interfaces.score.IScoreExModelPlaceService;
import com.osce.score.mapper.ScoreExModelPlaceMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 考试模版考场表Service业务层处理
 *
 * @author zzx
 * @since 2023-08-22
 */
@Service
public class ScoreExModelPlaceServiceImpl extends ServiceImpl<ScoreExModelPlaceMapper, ScoreExModelPlace> implements IScoreExModelPlaceService {


    /**
     * 查询考试模版考场表
     *
     * @param id 考试模版考场表主键
     * @return 考试模版考场表
     */
    @Override
    public ScoreExModelPlace selectScoreExModelPlaceById(Long id) {
        return baseMapper.selectScoreExModelPlaceById(id);
    }

    /**
     * 查询考试模版考场表列表
     *
     * @param scoreExModelPlace 考试模版考场表
     * @return 考试模版考场表
     */
    @Override
    public List<ScoreExModelPlace> selectScoreExModelPlaceList(ScoreExModelPlace scoreExModelPlace) {
        return baseMapper.selectScoreExModelPlaceList(scoreExModelPlace);
    }

    /**
     * 新增考试模版考场表
     *
     * @param scoreExModelPlace 考试模版考场表
     * @return 结果
     */
    @Override
    public int insertScoreExModelPlace(ScoreExModelPlace scoreExModelPlace) {
        return baseMapper.insertScoreExModelPlace(scoreExModelPlace);
    }

    /**
     * 修改考试模版考场表
     *
     * @param scoreExModelPlace 考试模版考场表
     * @return 结果
     */
    @Override
    public int updateScoreExModelPlace(ScoreExModelPlace scoreExModelPlace) {
        return baseMapper.updateScoreExModelPlace(scoreExModelPlace);
    }

    /**
     * 批量删除考试模版考场表
     *
     * @param ids 需要删除的考试模版考场表主键
     * @return 结果
     */
    @Override
    public int deleteScoreExModelPlaceByIds(Long[] ids) {
        return baseMapper.deleteScoreExModelPlaceByIds(ids);
    }

    /**
     * 删除考试模版考场表信息
     *
     * @param id 考试模版考场表主键
     * @return 结果
     */
    @Override
    public int deleteScoreExModelPlaceById(Long id) {
        return baseMapper.deleteScoreExModelPlaceById(id);
    }

    @Override
    public int deleteScoreExModelPlaceByModelIds(Long[] ids) {
        return baseMapper.deleteScoreExModelPlaceByModelIds(ids);
    }

    @Override
    public int batchScoreExModelPlace(List<ScoreExModelPlace> scoreExModelPlaceList, Long modelId) {
        if (ListUtil.isEmpty(scoreExModelPlaceList)) {
            return 0;
        }
        scoreExModelPlaceList = scoreExModelPlaceList.stream().peek(t -> t.setModelId(modelId)).collect(Collectors.toList());
        return baseMapper.batchScoreExModelPlace(scoreExModelPlaceList);
    }

    @Override
    public int deleteScoreExModelPlaceByModelId(Long id) {
        return baseMapper.deleteScoreExModelPlaceByModelId(id);
    }
}
